import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


// getParameter比较常用
@WebServlet("/getParameter")
public class GetParameterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 预期浏览器传来一个形如这样的请求: /getParameter?userId=123&classId=456
        String userId = req.getParameter("userId");//分别对应上面的userId和classId
        String classId = req.getParameter("classId");
        // 将数据返回到浏览器上
        resp.getWriter().write("userId=" + userId + ", classId=" + classId);
    }

//    网页上:http://127.0.0.1:8080/hello102/getParameter
//    返回:userId=null, classId=null
//    因为你没有输入任何内容


//    网页上:http://127.0.0.1:8080/hello102/getParameter?userId=10&classId=20
//    返回:userId=10, classId=20
}